<?php
header('Content-Type: application/json');
Header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE');
header("Access-Control-Allow-Headers: Content-Type");
header('Access-Control-Allow-Origin:*');   //跨域


require './data.php';


if ($_SERVER['REQUEST_METHOD'] === 'GET') {       //判断是否是get请求
     sleep(0.4);         //睡眠，防止恶意刷验证码消耗服务器资源
    $response = array(
        'status' => hash('sha256',$captcha.'jiaoyan'),      //对校验码加密，伪装
        // 'status' => $captcha,      //未进行校验码加密，伪装
        'message' => 'captcha/picture.php?id='.rand(),
    );

    echo json_encode($response);

}else{
    $response = array(
        'status' => 'fail',
        'message' => '请求方式错误',
    );
    echo json_encode($response);
}

?>
